Harry Potter and the Integrated Sciences
by ladyowl
Summary: Our favorite hero has gone to university to study the Integrated Sciences, the combination of muggle and magical knowledge for a better understanding of the world. Watch him discover the Laws of Thermodynamics, Stability, and more...
1. The Laws of Thermodynamics

The Laws of Thermodynamics

The first time I was told the three Laws of Thermodynamics, I forgot all about them. It's understandable. I was maybe 10, and everything was packaged quite nicely as a Conservation of Energy thing. "Don't worry why it makes sense, just learn it."

The second time I was told them, I thought they were interesting, but kind-of useless. I had just finished my seventh year at Hogwarts, after all. It wasn't like I was going to be interested in "muggle science." Right.

The third time I was told them, they just about blew my mind. It was one of these"This Changes Everything I've Ever Thought About Magic. Ever." moments. A "Hang On. You Mean Magic Could Be Rational?" moment. A "Professor Vokaspszky, I Want To Marry You" moment. Maybe not that extreme.

To be perfectly fair, I'll grant you that the zeroth law is not particularly interesting to me. It sounds a bit like a truism: if internal energy in system A is equal to energy in systems B and C, then of course B and C must have the same internal energy. Definition of equality, right?

But the two main Laws of Thermodynamics are pretty important. We're used to thinking that magic is limitless: that because we have "Our Will and Our Wand" we can do anything we want. That we're not bound to any of the "silly natural laws" muggles always complain about. But, when you think deeper about it – or when your favorite Integrate Sciences professor pushes your nose into the implications – you can see that just because you're a wizard doesn't mean you're not human too.

From the muggle form of the first law, we know that the net change in a system's energy (E) must account for all of the energy that enters or leaves the system as work or heat. But, magic is also a sort of energy, so it can probably be accounted for too.

So, all of those times I saw someone lift a feather with a nice Wingardium Leviosa, I was really just someone putting energy into the feather system. We should call the amount of energy put in by castor magical energy (M) for the sake of simplicity. I'd like to hypothesize that:

ΔE = ΔQ – ΔW + ΔM.

So, if I lift a 1kg pound of bread 1m above its original resting place, I still use 9.8J of energy. It just isn't my muscles doing the work. So, the mechanical work done on the bread (ΔW) is 0J, but the magical work done on the bread (ΔM) is still 9.8J.

The real test of this idea, of course, comes from attempting to verify a prediction made with the hypothesis. So here goes: if you cast a wingardium leviosa on a feather/loaf-of-bread/other-experimental-object, while physically lifting the feather/etc, you should be able to get the feather/etc to rise higher in the air then if you just cast or lift alone. Just to make sure we've actually got a repeatable test, lets perform each test 30 times, with say, 10 different test subjects. Anyone in need of a thesis?

I should make a note here, that the usual safety caveats do apply: the mass of the bread should not change, the bread should not catch on fire, etc. etc. I'm sure you remember those burnt feathers from Flitwick's class as much as I do.

And the sign convention is arbitrary. Heat (ΔQ) and magic are positive when added to the system, but mechanical work is positive when done by the system. Yes. Yes. We've all heard the complaints before...

Naturally, we all know it feels much easier to lift 1 kg of something with magic than it does by hand. Otherwise, how on Earth would Merlin have raised his castle? Hmm? Point being that clearly the magical energy doesn't all come from the castor: it's somehow amplified by the wand. Yes, now we know why only Dumbledore does wandless magic. And why he only ever uses it to do small things like putting out candles. Because without your focus, there's no way anyone is going to collect the energy to do anything worthwhile.

So, logically we want to know how this amplification thing works, right? Well. We know a few things. First, that you need a focus of some kind: wand, or staff or whatever. And, it follows that not all focuses are equal. Witness the "Wand Chooses the Wizard" phenomenon. And then try casting lumos with a rock. Second, the magical ability of a person is important – otherwise, what difference could being a squib possibly make? Third, there's some relation to intent. I know, the last phrase sounds odd, but really, we need some reason why accidental magic only happens when you're really desperate. Fourth, we must have some amount of energy expended by the castor. Otherwise, you would never feel tired after casting some difficult spell.

I can't really say I know much about the relationship between the amplification factors. Maybe it's exponential. Maybe there's a summation and a multiplication. A reasonable way to find out might be to try lifting a given feather/loaf-of-bread/other-experimental-object with wingardium leviosa while varying a) focii, b) the magical ability of the castors, c) the incentive given to the castor, and d) the change in heart-rate of the castor from before to after the actual casting. If we measure the hight the feather reaches for every combination of factors, we might find our relationship. I'll pity whatever number-cruncher gets to do the curve fitting on the results, though.

I'll grant you that a lot of these factors are highly subjective, so it may be best to use extreme values. Say: a rock vs. the castor's normal wand. Or: I'll kick you in the balls, if you don't cast this spell vs. I'll give you half of a chocolate frog if you cast this spell. Also, test-subject expectations might be difficult to compensate for. And, clearly, we'd need a lot of experimental repeats. Just to be on the safe side.

Then the next big step: the second law of thermodynamics.

The muggle version of the second law has multiple descriptions of this law. Luckily for us, they're all equivalent and interchangeable, so let's just use the Kelvin-Planck description. In the words of the famous Professor Vokaspszky, "No process is possible whose sole result is the absorption of heat from a reservoir and the conversion of this heat into work." That is, when you drive a process with heat, some heat must always be exhausted.

A Carnot engine is, as I'm sure you remember, an imaginary, ideal mechanism for converting heat into useful work. The Carnot engine exhausts the minimum amount of heat required by the second law of thermodynamics. Naturally, the standard understanding of a Carnot engine is purely muggle. But, if we assume, as we have done implicitly from the beginning, that magic is a form of energy which can be used to drive processes and is never exhausted, then we can come up with an adjusted idea of the Carnot cycle.

To make sure that our adjusted second law holds, let's check whether our efficiency when lifting feathers/loaves-of-bread/other-experimental-objects is less than the adjusted Carnot efficiency for the same task. An insulated castor is sealed into an insulated room with the test feather/etc. We can either assume that specific heat does not change in magically-saturated air and look it up in a table, or we can measure it ourselves by working backwards from the first law. We need to measure the temperature of the air before the trial, and when the feather reaches its maximum height. We'll also use our recently measured relationship for magical energy when the feather reaches its maximum height. Let's not forget to measure the weight of the feather and the maximum height it reaches.

Now we have a source of heat (Qin) and magic (M), and a measured amount of useful work (W) and exhaust heat (Qout). In the case of lifting a feather/etc, the heat source is the ambient heat in the room before the spell is cast and the magic source is the castor. The useful work is the change in potential energy of the feather when the feather reaches its maximum height. The exhaust heat is the ambient heat in the room when the feather reaches its maximum height. So, all of the relevant values are known, because heat is simply the product of specific heat and temperature.

The actual efficiency of our lifting process is

W/(Qin+M).

And, the adjusted Carnot efficiency based on our modified first law would be

(Qin+M-Qout)/(Qin+M)=1-Qout/(Qin+M).

If we repeat this experiment multiple times, and never have an actual efficiency higher than the predicted Carnot efficiency, we are probably safe in saying that the second law is true even when magic is considered. Of course, the number of trials is critical to our ability to draw a conclusion.

This is big stuff, though, right? I know I used to think, "Well, sure. Let's wave the wand a bit, and then something interesting will happen." But, no, there really does seem to be a method to this madness. And no, magic isn't just – as my Uncle Vernon used to say - "lazy, good-for-nothing freaks trying to avoid real work." Even with magic, work won't get done for free, and you still usually get less than you pay for.

And, while none of this can actually be proven or explained, at least it can be observed.

So, maybe we can say that magic is – at least – a little bit logical. I know we're still got some trouble with spacial continuity. And, yes, the time travel thing is a bit tricky. But, hey, I'm still a grad student. One who doesn't get paid nearly enough to solve these types of problems, I might add.

Well, I'm off back to lab. It was nice talking with you.

AN: Thanks to the real Professor Vokaspszky. And of course, to J., whose universe I've invaded.


	2. Stability

Stability

When I left lab yesterday, I bumped into Professor Lahl. Neither of us was in a rush, so we traded pleasantries, and he told me what he's working on. Apparently, he's got a grant to work on broom design . He wouldn't admit to it being from Nimbus, but I'm sure we can all draw our own conclusions. Their goal seems to be a balance between the broom's stability and maneuverability.

Every system, whether a modern broom, or a muggle thermostat, can be described by three things: the stimuli that determine the system's behavior, the responses the system gives to the stimuli, and the relationship between the stimuli and the responses. So, the stimuli on a broom might be aerodynamic shape, angle towards the wind, current speed, weight of the rider, and so on. The responses from the broom would be acceleration, or change in direction, etc. For a thermostat, the stimuli would probably be the current air temperature and the resident's desired temperature. The response would be a heater that is on or off. Unless you've got a particularly fancy model that only comes on at midnight when we're astrologically in Jupiter, in which case I'll wash my hands of the entire thermostat issue. Point is: sometimes the stimuli, response and relationship are complicated, sometimes they're pretty simple.

Brooms happen to be one of these complicated issues, which of course also makes any sort of optimization complicated.

The basic definition of a broom's stability depends on the how much a broom's responses change when the stimuli change. From what I remember of Professor Lahl's class, a broom is stable only if the changes in the response are small when there's a small change in stimuli. So, if you lean hard to the left, and the broom doesn't turn much, it's a stable broom. If, on the other hand, you snag one of your bristles, and the entire thing takes a nose-dive, then the broom's unstable, and you'll have Pomfrey on your case all season. Anyway, it's a bit of a trade-off, because clearly a seeker needs to be able to turn and accelerate quickly in order to catch the snitch.

Clearly, I'm oversimplifying the story.

How exactly do you want to test whether your broom is stable or not? There are two standard ways to go about it: Bounded-Input-Bounded-Output (BIBO) Stability and Zero-Input Stability.

In both cases, you have to assume that before you conduct your stability test you're flying along like you're on a Sunday stroll. You're completely relaxed. Perfectly horizontal flightpath. Not doing anything exciting at all. Just cruising.

Right. Then. For BIBO Stability you ask: if I were to continuously change the broom's stimuli by a constant, finite, and measurable amount, would the responses change by a finite, measurable amount too? Would the broom eventually nose-dive? Just for the record, this is usually called an "exploding" response. You can tell it's not pleasant. If the response change is finite and measurable, then your broom is stable.

To test for Zero-Input Stability, you have to very quickly give your broom some strange stimuli. But right afterwards, you have to return to normal stimuli. It would be like touching your head to the broom handle for a tenth of a second, before returning to normal posture. The broom can then do one of three things: it can continue to travel along the path your jerk provoked, it can return to the original path before the jerk, or it can nose-dive.

Now, suppose you want to know whether the broom is BIBO and Zero-Input stable without actually getting on the broom and risking your neck. At the very least, you want to do the minimum neck-risking possible. Sounds fairly reasonable, right?

Well, everything really comes down to the relationship between the stimuli and the responses. You need a function to model this relationship. This function is usually called the impulse response (g) of the system. So, the trick will be to find the broom's impulse t response.

We either know a system's impulse response by our own design, or we have to go and test it experimentally. To find it experimentally, you would fly the broom, and give a short impulse to the stimuli. If you repeated this multiple times, you could curve-fit, until you had an actual function. I can't say I've got any idea what proprietary impulse response Professor Lahl's broom design has, but I can bet it's top-secret and incredibly impressive.

But, for the sake of our thought experiment here, let's assume it's some nice impulse response. What about:

g(t) = exp(-9 t).

To do interesting things with known impulse responses, you generally have to find their equivalent transfer functions (G). Which is lucky, because it gives us an excuse to take a Laplace transform. And they are lots of fun, if you've got a table, a nice function, and only one transform to take. Anyway.

G(s) = L[g(t)] = 1/(s+9).

So. that was exciting.

To get back to our main question, though, we want to know if this broom is stable. Both BIBO and Zero-Input, preferably.

We have two ways to go about finding BIBO stability. By basic definition, the broom is BIBO stable - if and only if – there is a finite integral of g(τ) with respect to τ, from zero to infinity. Sometimes this integral will be fun, sometimes it won't. So, it's lucky we've got another way. Let's call the system stimuli r(t), and the response y(t). If we Laplace these two functions, we'll have R(s) and Y(s), respectively.

It's lucky that we found the impulse response earlier, because it means that we know two things. First, that R(s) must equal 1. By definition. Yes, go ahead and clap if you want. The second thing we know is that there is an easy relationship between R(s), Y(s) and G(s):

Y(s) = R(s) G(s) = G(s).

So, let's solve back to find the system response in real time y(t).

It's at this point that I'm very, very glad I chose a nice impulse response. And I'm very, very glad not to be one of Professor Lahl's grad students, who probably don't have such a nice one. Because we're going to end up with a response that fits into this sort of pattern:

y(t) = Σ ai exp(αi t),

and you can bet that the universe is cruel and gives many-term responses with complex exponentials whenever it feels like making you scramble. I'm tempted to say that I'd rather take a Dark Lord and maze, anyday.

But, back to BIBO stability. When you have the form of your system response, you look at the various αi's to determine stability. You can look up all of the combinations, if you want. But: basic fact is that if the real term of all of the αi's is negative, the broom will tend to return to it's original path after it's been hit with an impulse. And if any real term is positive, you're not likely to end up looking very happy. In this case, it looks like we're safe since -9 is clearly negative.

So, how do we find if a broom is Zero-Input stable? The neat thing here is that by some fast algebra, you can prove that – under most conditions, anyway - Zero-Input stability and BIBO stability are the same thing.

Well, you say: we can decide if a broom is stable if we know it's impulse response or if we can fly it. But, what if we're still designing the thing? How do we decide what impulse response we want to give the broom? Luckily there's a way to do this without having to endlessly repeat the BIBO test.

The Routh test has two conditions, and depends on something called the characteristic equation. A system's characteristic equation (Δ(s)) is really just the equation you get when you set the denominator of the transfer function equal to zero. If we keep using the equation from above:

Δ(s) = s+9 = 0.

Now let's look at the conditions. Condition 1: every power of s – less than the highest power – must have a positive, non-zero coefficient. That is, neither

s^3+s+9 = 0, nor

-s+9 = 0

can possibly be stable. But,

s+9=0

still has a chance.

Condition 2: when the characteristic equation is arranged into a Routh array, all of the first column values must be positive. The Routh array is an (n+1)x((n+1)/2) array that you get by plugging in the coefficients of the characteristic equation into the first two rows, and then performing operations on them to find the values in the next (n-1) rows.

The coefficient of the highest powered s-term belongs in the [n+1.1] spot; that of the next highest term in the [n,1] spot; that of the next term in the [n+1,2] spot; the next term coefficient in the [n,2] spot; and so on, until you run out of coefficients. From there on, every remaining spot should be filled by the product of the [2 above present row, 1] value and the [1 above present row, 1 right of present column] value minus the product of the [2 above present row, 1 right of present column] value and the [1 above present row, 1] value. And normalized against the [2 above present row, 1] value. It all sounds silly when you put it in words, but it seems to work pretty well. If we go back to our example:

1 0

9 0

0 0.

It's like we thought. This broom is stable.

Well, the usefulness comes in when you're trying to decide what characteristic equation – so, what transfer function and impulse response – you want your broom to have. You just add in some unknown into the transfer function, and check the conditions like normal. Just to show it, if we had the characteristic equation:

Δ(s) = s^2+Ks+9 = 0,

then our Routh array would be:

1 9 0

K 0 0

-9K 0 0

0 0 0.

Then we can say that no K can possibly make this broom stable: because K must be positive and non-zero for condition 1 to hold, but K must be either negative or zero for condition 2 to hold. And suddenly, we know we don't need to bother with this form of characteristic equation. Without doing any transforms at all.

Then, you keep suggesting possible forms of characteristic equations, and checking if they could possibly be stable. And then solve back from characteristic equation to transfer function to impulse response. And then hopefully to a physical broom design.

Anyway, I don't even know why I'm whining on about this instead of working. Maybe because it's cold out, I'm nostalgic for quidditch, and I don't particularly feel like real work anyway. I think I'll just push off and head home for the night. Until later, I guess.

AN: This time, thanks goes to the real Professor Lahl.


End file.
